package com.itheima.dao;



import com.itheima.domain.OrderData;
import com.itheima.domain.Setmeal;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface OrderDataDao {
    /**
     * 根据会员id、预约日期、套餐id查询预约信息
     * @param temp
     * @return
     */
    OrderData findByMemberIdAndOrderDateAndSetmealId(OrderData temp);

    /**
     * 保存预约信息
     * @param temp
     */
    void add(OrderData temp);

    /**
     * 根据id查询预约信息
     * @param id
     * @return
     */
    Map findById(Integer id);

    /**
     * 查询对应数日的预约数
     * @param reportDate
     * @return
     */
    Long findCountByEqualDate(String reportDate);
    /**
     * 查询对应数日的到诊数
     * @param reportDate
     * @return
     */
    Long findVisitedCountByEqualDate(String reportDate);

    /**
     * 查询大于等于对应数日的预约数
     * @param reportDate4ThisWeek
     * @return
     */
    Long findCountByGreateAndEqualDate(String reportDate4ThisWeek);

    /**
     * 查询大于等于对应数日的到诊数
     * @param reportDate4ThisWeek
     * @return
     */
    Long findVisitedCountByGreaterAndEqualDate(String reportDate4ThisWeek);

    @Select("select count(id) from t_order where orderDate=#{value}")
    Integer findOrderCountByDay(String today);

    @Select("select count(id) from t_order where orderDate>=#{value}")
    Integer findOrderCountByWeek(String thisWeekFirstDay);

    @Select("select count(id) from t_order where orderDate>=#{value}")
    Integer findOrderCountByMonth(String thisMonthFirstDay);

    @Select("select count(id) from t_order where orderDate=#{value} and orderStatus='已到诊'")
    Integer findVisitCountByDay(String today);

    @Select("select count(id) from t_order where orderDate>=#{value} and orderStatus='已到诊'")
    Integer findVisitCountByWeek(String thisWeekFirstDay);

    @Select("select count(id) from t_order where orderDate>=#{value} and orderStatus='已到诊'")
    Integer findVisitCountByMonth(String thisMonthFirstDay);

    @Select("select s.name,remark,count(o.id) setmeal_count,count(o.id)/(select count(id) from t_order) proportion from t_order o inner join t_setmeal s on s.id=o.setmeal_id group by o.setmeal_id order by setmeal_count desc limit 0,4")
    List<Map> findMostOrderSetmeal();

    @Select("select remark from t_setmeal")
    List<Setmeal> findExplain();
}
